package com.example.smartcity_poverty.ui.Home.adapter

import android.content.Intent
import com.example.smartcity_poverty.App
import com.example.smartcity_poverty.App.Companion.url
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.logic.model.NewsModel
import com.example.smartcity_poverty.logic.util.Util.glide
import com.example.smartcity_poverty.ui.ShowNewsActivity
import kotlinx.android.synthetic.main.re_item_hot.*

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *
 **/
class HotAdapter (
    private val list: MutableList<NewsModel.RowsBean>,
    private val layoutId: Int
) : BaseRecyclerAdapter<NewsModel.RowsBean>(list, layoutId){
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: NewsModel.RowsBean,
        position: Int,
        holder: BaseViewHolder
    ) {

        // 添加动画
        holder.itemView.animation = App.getAnimationEndAndStart()


        val d = list[position]
        glide(url + d.cover, holder.viewFind.hotImage)
        holder.viewFind.hotTitle.text = d.title

        val con = holder.viewFind.view?.context
        holder.itemView.setOnClickListener {
            con?.startActivity(Intent(con, ShowNewsActivity::class.java).apply {
                putExtra("id", d.id.toString())
            })
        }

    }

}